{extend name="public/base"}

{block name="title"}
登录
{/block}

{block name="style"}
{css href="/static/wechat/css/login.css" /}
{/block}

{block name="body"}
<div class="pageControl login">
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">注册</h1>
    </div>
    <div class="weui-top">
        <div class="logo">
            <img src="/static/wechat/images/logo_03.png">
        </div>
        <form action="{:url('save_register')}" method="post" id="form"  class="register_form">
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">+86<i class="micon-in"></i></label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="number" name="phone" placeholder="请输入手机号码">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="password" name="password" placeholder="6-20位数字、字母组合">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">验证码</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="number" name="code"  placeholder="请输入验证码">
                    </div>
                    <div class="weui-cell_ft">
                        <button class="weui_cell-verify js-verify cl-orange">获取验证码</button>
                    </div>
                </div>
                <div class="weui-cell mt10">
                    <div class="weui-cell__hd"><label class="weui-label">邀请码</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="number" name="parent_phone"  placeholder="请输入邀请码,选填">
                    </div>
                </div>
            </div>
            <div class="msui_button">
                <div class="msui_button-hd">
                    <p class="cl-orange referrer"></p>
                </div>
                <div class="msui_button-bd">
                    <a class="msui_button-content member_form">注册账户</a>
                </div>
                <div class="msui_button-ft">
                    <p>注册即表示您已阅读并同意<span class="cl-orange"> <a href="{:url('base/member_service_contract', ['id' => 12])}">< 开摩邦网服务协议 ></a> </span></p>
                </div>
            </div>
        </form>
    </div>


</div>
<!-- loading toast -->
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">加载中...</p>
    </div>
</div>
{/block}

{block name="javascript"}
{js href="/static/wechat/js/login_form.js" /}
<script>
    $(function () {

        $('input[name="parent_phone"]').bind('input propertychange', function() {
            var _this = $(this);
            var phone = _this.val();
            if (phone.length == 0) {
                $(".referrer").text('');
                return false;
            }
            if (phone.length != 11) {
                $(".referrer").text('请输入正确的推荐人手机号码！');
                return false;
            }

            $('#loadingToast').fadeIn();
            $.get("{:url('get_referrer')}", {phone : phone}, function (msg) {
                $('#loadingToast').fadeOut();
                if (msg.code == 200) {
                    $(".referrer").text('推荐人：' + msg.data.proposer);
                } else {
                    var code = msg.code;
                    $(".referrer").text(error_code[code]);
                }
            }, 'json');
        });
    });
</script>
{/block}